home *** CD-ROM | disk | FTP | other *** search
- /*
- * LVS Windows
- * The Window Class System
- *
- * Copyright 1991 (c), Lake View Software
- * 4321 Harborough Rd.
- * Columbus, OH 43220
- * All rights reserved.
- */
- // WinObj.hpp
-
- #ifndef WINOBJ_HPP
- #define WINOBJ_HPP
-
- #include <stdio.h>
- #include "win.h"
-
- typedef int (*valid_func)(void *);
- typedef void (*before_func)(void *);
- typedef void (*mouse_routine_t)(int, int);
-
- // Get Object
- class GetObj {
- friend class WinObj;
- GetObj *Prev_get;
- GetObj *Next_get;
- int y, x;
- int len, dec;
- int type; // Type of data
- void *obj; // Data pointer
- char style; // Style for strings
- char *picture; // Picture to use for strings
- valid_func valid; // Call after read to get
- before_func before; // Call before read to get
- int help_level; // Help to use
- int Hot_Key; // Key to trigger a user popup
-
- /* Paradox Stuf */
- unsigned PX_rec; // Paradox record handle
- unsigned PX_tbl; // Paradox table handle
- unsigned PX_fld; // Paradox field handle
- char PX_type [10]; // Paradox field type
- void *PX_buf; // temp Buffer for px field
- };
-
-
- // Window Object
- class WinObj {
- friend class WinMouse;
- friend WinObj *Win_whos_active ();
- friend void Win_close_all ();
- protected:
- static WinObj *w_active; // Current active window object
- static int w_count; // number of window objects
- WinObj *next_win; // Next window object
- WinObj *prev_win; // Previous window object
- int wsc,wsr,wec,wer; // Screen coordinates
- int width,height; // Actual screen space available
- int get_attr; // Get attribute
- int win_attr; // Window attribute
- int bor_attr; // Border attribute
- int bor_type; // Border type
- int win_type; // type of window
- char fill_char; // window fill character
- int title_pos; // Title position
- char *title_str; // Pointer to title string
- char *wdata_buf; // Data buffer
- char *wattr_buf; // attribute buffer
- GetObj *Current_get; // Current get object
- GetObj *Last_get; // Last get object in list
- char opened; // Opened flag
- char hidden; // Hidden flag
- char needs_display; // Refresh flag
- char has_border; // border flag
- char has_shadow; // shadow flag
- char any_change; // any read changes
- char scroll_h,scroll_v; // scroll arrows flag
- unsigned vh,vw; // Virtual height and width
- unsigned buf_size; // Window data and attr buf size
- unsigned sx,sy; // Start x and y for virtual display
- unsigned cur_pos; // Cursor x and y
- void reset_window (); // reset all flags
- int get_titlestart (int &len); // get start x of title and length
- int input (GetObj *Obj); // Get a read from the screen
- int create_get (int y, int x); // create a new get object
- void show_get (GetObj *Obj); // Display get on screen with get attr
- void draw_border (); // draw the window border
- virtual char bor_char (int, int, char &);// calculate the border char/attr
- void update_scroll (); // update scroll bars
- virtual void display (); // Display window contents on top
- virtual void update (int start_pos,int len); // Update a portion of window
- void show_shadow (); // Display the windows shadow.
- virtual void mouse_routine (int y, int x); // mouse click routine
- mouse_routine_t mouse_user_routine; // programmers mouse routine
-
- /* Paradox Stuf */
- unsigned PX_tbl, // Paradox table handle
- PX_rec; // Paradox record handle
- public:
- WinObj (int v_h=0, int v_w=0);
- ~WinObj ();
-
- char *get_version ();
- int set_virtual (int y,int x); // set virtual size
- virtual int open (int sr, int sc, int er, int ec,
- int btype=W_DOUBLE, int wattr=_BLACK|LGREY,
- int battr=_BLACK|LGREY); // Open the window object
-
- /* Mouse related */
- mouse_routine_t set_mouseroutine (mouse_routine_t); // programmers mouse routine
-
- /* Attributes */
- int set_attr (int color); // Returns pervios attribute
- void set_attr (int color, int y,
- int x, int cnt=1); // change attr
- void set_fill (char fill); // set window fill character.
- void change_border (int type,
- int color=-1); // Set new border style/color
- void title (char *str,
- int position=W_CENTER); // Change the window title
- virtual void shadow (int on_off=W_ON); // Turn window shadow on/off
-
- /* Display routines */
- void box (int sr, int sc, int er,
- int ec, int type = W_SINGLE); // Draw a box in the window
- virtual void update (); // Update but don't set current
- void update_all (); // update all open windows
- virtual void show_cursor (); // Show cursor in window
- virtual void close (); // Close the window object.
- virtual void set_active (); // makes window current window
- void bprintf (char *,...); // Print f in window
- void bprintf (int y, int x, char *,...); // xy bprintf
- void printf (char *,...); // Print f in window
- void printf (int y,int x,char *,...); // xy printf
- void puts (char *,int translate=W_ON); // Display a string
- void puts (int y, int x, char *, int translate=W_ON);
- void putch (char ch, int translate=W_OFF); // display a character
- void putch (int y, int x, char ch, int translate=W_OFF);
- int center (int y, char *); // center in virtual window
- void clr_win (); // Clear window
- void clr_eol (); // Clear to end of current line
- void clr_eow (); // Clear to end of window
- void del_line (int line_no); // Delete current, line pull up
- void ins_line (int line_no); // Ins new line, push down
-
- /* Get routines */
- int get (int y, int x, char *str, char *picture=NULL);
- int get (int y, int x, char *str, char style, int len = 0);
- int get (int y, int x, char &ch);
- int get (int y, int x, int &geti, int len=4);
- int get (int y, int x, long int &getl,int len=5);
- int get (int y, int x, double &getd, int len=10, int dec=2);
- int set_getattr (int new_attr); // Change the get attribute
- int valid (valid_func func); // Valid function
- int before (before_func func); // Before get function
- virtual int get_key (int echo=W_NOECHO, int seconds = 0); // Get single key from keyboard do not echo, wait forever
- virtual int read (int clear = 1); // Read all defined gets
- int any_read_change (); // any change after last read
- int update_gets (); // Update gets on screen.
- void clear_gets (); // Clear all defined gets
-
- /* Window Movement */
- virtual void hide (); // Hide window
- virtual void unhide (); // Show window
- virtual int move (int new_y, int new_x); // Move the window
- virtual int size (int new_height, int new_width); // Resize the window
- WinObj& gotoxy (int y=0, int x=0); // Move cursor in window
- int pan (int delta_y, int delta_x); // change pan location
- int set_pan (int y, int x); // set pan location
-
- /* Information routines */
- int do_youown (int y,int x,char &ch,char &attr); // Do you own screen position
- WinObj *who_owns (int y,int x,char &ch,char &attr);
- WinObj *whos_below (int y, int x, char &ch, char &attr);
- unsigned max_x(), max_y(); // return maximum virtual x/y coordinates
- int get_scr (int &sr, int &sc, int &er, int &ec); // get coordinates
- int get_pan (int &y, int &x); // return current pan coordinates
- int wherexy (int &y, int &x); // return current cursor pos
- int wherex (); // return current col
- int wherey (); // return current row
- int is_open (); // open status
- int ret_char (int y, int x); // get window char at window location
- int ret_attr (int y, int x); // get window attr at window location
- int text_save (FILE *fp); // save window text
- int text_retrieve (FILE *fp); // retrieve window text
-
- /* Paradox get / read routines */
- int PXrecord (unsigned tbl_handle, unsigned rec_handle);
- int PXget (int y, int x, unsigned fld_handle);
- int PXget (int y, int x, unsigned fld_handle, int len, int dec);
- int PXget (int y, int x, unsigned fld_handle, char style);
- int PXget (int y, int x, unsigned fld_handle, char *picture);
- int PXread (int clear=1); // use this read with PX
-
- /* Overloaded operators */
- WinObj& operator << (int i);
- WinObj& operator << (char *str);
- WinObj& operator << (char ch);
- WinObj& operator << (long l);
- WinObj& operator << (double d);
- WinObj& operator << (float f);
- WinObj& operator << (unsigned ui);
- WinObj& operator << (unsigned long ul);
- };
-
- /*
- * Global functions
- */
- extern WinObj *Win_whos_active ();
- extern int printf_translate (int mode);
-
- /*
- * Some macros for internal use
- */
- #define SHADOW_ATTR DGREY
- #define BUFFER_OFFSET(y,x) (y * vw + x)
- #define GET_REAL_X(x) ((x - sx) + wsc + has_border)
- #define GET_REAL_Y(y) ((y - sy) + wsr + has_border)
- #define CALC_SCROLL_POSITION(s,x,a_rng,b_rng) ((a_rng) ? (s + 2 + (int)((long) (x) * (long)(b_rng) / (long)(a_rng))): 0)
-
-
- /*
- * Class to save the current screen state to restore it when the
- * program is finished.
- */
- class ScreenState {
- private:
- int restore; // restore state on exit flag
- int page; // previous screen page
- int *scr_buf; // screen buffer
- int y, x; // cursor location
- int rows, cols; // row/col count
- int mode;
- public:
- ScreenState ();
- ~ScreenState ();
- };
-
-
- #endif // #ifndef WINOBJ_HPP
-